﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace OINS_VS08
{
    class Client
    {
        public void Run()
        {
            TcpClient socketForServer;
            try
            {
                socketForServer = new TcpClient("localHost", 65000);
            }
            catch
            {
                Console.WriteLine("nieudane polaczenie z adresem {0}: 65000", "localHost");
                return;
            }
            NetworkStream networkStream = socketForServer.GetStream();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
            try
            {
                string outputString;
                do
                {
                    outputString = streamReader.ReadLine();
                    if (outputString != null)
                    {
                        Console.WriteLine(outputString);
                    }
                }
                while (outputString != null);
            }
            catch
            {
                Console.WriteLine("NIeudany odczyt danych");
            }
            networkStream.Close();
        }
    }
}




